import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:huajianshe_app/base/BaseState.dart';
import 'package:huajianshe_app/common/load_image.dart';
import 'package:huajianshe_app/common/res.dart';
import 'package:huajianshe_app/widget/SmartButton.dart';
import 'package:huajianshe_app/widget/appbar/CAppBar.dart';

class LabelListPage extends StatefulWidget {

  @override
  State<StatefulWidget> createState() {
    return _LabelListPageState();
  }
}

class _LabelListPageState extends BaseState<LabelListPage> {

  final TextEditingController searchController = TextEditingController();
  final FocusNode searchNode = FocusNode();

  @override
  Widget build(BuildContext context) {
    return
      Scaffold(
        backgroundColor: Colors.white,
        appBar: CAppBar(title: '标签', overlayStyle: SystemUiOverlayStyle.dark, backImgUrl: 'ic_black_arrow',),
        body: Column(children: [
          H(10),
          Padding(padding: EdgeInsets.symmetric(horizontal: 15), child:SizedBox(height: 44, child: Stack(children: [
            TextField(
              autofocus: false,
              controller: searchController,
              focusNode: searchNode,
              textInputAction: TextInputAction.search,
              onSubmitted: (value) {
                print('submit $value');
                doSearch(value);
              },
              decoration: InputDecoration(
                isDense: true,
                contentPadding: EdgeInsets.only(left: 30, right: 10, top: 15, bottom: 15),
                fillColor: C.grayF6,
                filled: true,
                border: new OutlineInputBorder(
                  borderSide: BorderSide.none,
                  borderRadius: const BorderRadius.all(const Radius.circular(13.0)),
                ),
                hintStyle: TextStyle(fontSize: 13, color: C.gray666),
                hintText: '搜索标签名称',
              ),
            ),
            Positioned.fill(child: Align(alignment: Alignment.centerLeft, child: LoadImage('ic_search')), left: 12)
          ]))),
          H(20),
          Row(mainAxisAlignment: MainAxisAlignment.end, children: [
            SmartButton(text: '新建标签', fontSize: 15, textColor: C.primary, drawableLeft: LoadImage('ic_add_label'),
                drawablePadding: 5, backgroundColor: Colors.transparent, borderColor: Colors.transparent, onPressed: addLabel,),
            W(15),
          ]),
          H(10),
          Padding(padding: EdgeInsets.symmetric(horizontal: 15), child: Expanded(child: ListView.separated(
              itemBuilder: (BuildContext context, int index) {
                return Text('1');
              },
              separatorBuilder: (BuildContext context, int index) {
                return DD();
              },
              itemCount: 1
          )))
        ])
      );
  }

  doSearch(String text) {

  }

  addLabel() {

  }
}